﻿using SortGUI.cn.com.webxml.www;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
namespace SortGUI
{
    public class WeatherService
    {
        public void WeatherReporter(string cityName, PictureBox weatherPictureBox, Label weatherLabel)
        {
            try
            {
                WeatherWebService w = new WeatherWebService();
                string[] s = w.getWeatherbyCityName(cityName);

                if (s[8] == "")
                {
                    MessageBox.Show("暂时不支持您查询的城市");
                }
                else
                {
                    weatherPictureBox.Image = Image.FromFile(@"Resources\weathericon\" + s[8] + "");
                    weatherLabel.Text = s[1] + " " + s[6];
                }
            }
            catch
            {
                MessageBox.Show($"无法查询天气,请检查您的网络连接。\n点击确定进入脱机模式", "⚠警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}

